// Chrometris 1.0 for Chrome OS
// Copyright (c) 2010 Joseph Huckaby

Plane.extend( 'Playfield', {
	
	map: [],
	cols: 8,
	rows: 16,
	
	init: function() {
		// setup
		this.__parent.init.call(this);
		
		this.div = Port.addDiv({ id: 'playfield', x: 'center', y: 'center', width: 320, height: 640 });
		this.div.fadeIn( 30 );
		
		// clear tile map (used for logic only)
		for (var x = 0; x < this.cols; x++) {
			this.map[x] = [];
			var col = this.map[x];
			for (var y = 0; y < this.rows; y++) {
				col[y] = 0;
			}
		}
	},
	
	destroy: function() {
		// shutdown
		this.__parent.destroy.call(this);
		
		Port.removeDiv( this.div );
		delete this.div;
	},
	
	lookupTile: function(tx, ty) {
		var col = this.map[tx];
		if (typeof(col) == 'undefined') return 0;
		return col[ty] || 0;
	}
	
} );
